package com.wc.AlgoOJ_train.train1.c0.A010;

import java.util.Scanner;

/**
 * @Author congege
 * @Description
 * @Date Created in 2023/12/24-21:47
 */
public class Main {
    static int[] arr;
    static int idx = 1;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        arr = new int[999];
        for (int i = 100; i <= 999; i++) {
            if (isWaterNum(i)) {
                arr[idx++] = i;
            }
        }
        while (sc.hasNextInt()) {
            int m = sc.nextInt();
            int n = sc.nextInt();
            if (m > n) {
                m = m + n;
                n = m - n;
                m = m - n;
            }
            int first = halfSearch(m);
            int second = halfSearch(n);
            if (arr[second] != m) {
                second -= 1;
            }
            if (first > second) {
                System.out.println("no");
            } else {
                System.out.print(arr[first]);

                for (int i = first + 1; i <= second; i++) {
                    System.out.print(" " + arr[i]);
                }
                System.out.println();
            }
        }
    }

    public static int halfSearch(int val) {
        int l = 1;
        int r = idx - 1;
        int mid;
        while (l <= r) {
            mid = l + (r - l) / 2;
            if (arr[mid] >= val) {
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }

        return l;
    }

    public static boolean isWaterNum(int num) {
        int n = num;
        int ans = 0;
        while (n > 0) {
            ans += (int) Math.pow(n % 10, 3);
            n /= 10;
        }
        return ans == num;
    }
}
